
<template>
  <div class="team">
    <van-nav-bar
      :title="'粉丝('+teamNum+')'"
      left-text="返回"
      left-arrow
      :fixed="true"
      :placeholder="true"
      @click-left="$router.back(-1)"
    >
    </van-nav-bar>
    
    
    <van-pull-refresh
      v-model="Refresh"
      @refresh="onLoad"
      success-text="刷新成功"
    >
    <div v-show="customer.length==0&&!loading" >

      <img src="http://higuang365.com/public/images/common/icon/zanwufensi.png"/>
      <h3>暂无粉丝，继续加油吧！</h3>
    </div>
    <van-list
          v-model:loading="loading"
          :finished="finished"
          @load="onLoad"
          :key="3"
        >
      <div v-for="(value, index) in customer" :key="index">
        <customer :customer="value" />
      </div>
    </van-list>
    </van-pull-refresh>
  </div>
</template>
<script>
import { reactive, toRefs } from "vue";
import { GetMemberListInfoData,GetMemberNumber } from "@/api/user";

import { useStore } from "vuex";
import customer from "@/components/user/team/customer";
export default {
  components: {
    customer,
  },
  setup() {
    const data = reactive({
      customer: [
        // {
        //   name: "hg12321312",
        //   img: "https://iconfont.alicdn.com/t/4ce2b11e-32d1-4bf9-98b6-db6d83e7e891.png",
        //   member_id: 1,
        //   creaetedate: "2020-06-06",
        //   order_num: 10,
        //   // member_lv_id: 会员,
        //   mobile: "123456789JQK",
        // }
      ],
      Refresh: false,
      loading:false,
      finished:false,
      pageNum:1,
      pageSize:20,
      teamNum:0,
    });
    const store = useStore();
    const load=async () => {
      const res=await GetMemberNumber({member_id: store.state.userInfo.F_UserId,});
      if (!res[0]) {
        return;
      }
      data.teamNum=res[1][0].F_Qty;
    }
    const onLoad = async () => {
      if (data.Refresh) {
        data.pageNum = 1;
        data.customer = [];
        data.loading=true;
        data.finished = false;
      }
      const res = await GetMemberListInfoData({
        member_id: store.state.userInfo.F_UserId,
        pageNum: data.pageNum,
        pageSize: data.pageSize,

      });
      data.Refresh = false;
      data.loading=false;
      if (!res[0]||!res[1].length) {
        data.finished = true;
        return;
      }
      data.customer.push(...res[1]);
      if (res[1].length < data.pageSize) {
        data.finished = true;
      }
      data.pageNum += 1;
    };
    load();
    return { ...toRefs(data), onLoad };
  },
};
</script>
<style lang="scss" scoped>
.team {
  padding: 1rem;
  background: #f7f8fa;
  min-height: 100vh;
  font-size: 1.3rem;
}
</style>